package com.zs.members.controller;



import com.gsj.common.pojo.R;
import com.zs.members.pojo.vo.CouponVo;
import com.zs.members.service.CouponService;
import com.zs.members.pojo.entity.Coupon;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RestController;

/**
* <p>
    *  前端控制器
    * </p>
*
* @author 张硕
* @since 2021-07-25
*/

@Slf4j
@Api(tags = "优惠券控制")
@RestController
@RequestMapping("/members/coupon")
public class CouponController {

    @Autowired
    public CouponService couponService;

    @ApiOperation(value = "查询并分页）")
    @PostMapping("/get/{currentPage}/{pageSize}")
    public R get(@PathVariable("currentPage")Integer currentPage, @PathVariable("pageSize")Integer pageSize,@RequestBody CouponVo couponVo ){
        return couponService.get(currentPage,pageSize,couponVo);
    }

    @ApiOperation(value = "新增或修改")
    @PostMapping("/saveOrUpdate")
    public R saveOrUpdate(@RequestBody Coupon coupon){
        couponService.saveOrUpdate(coupon);
        return  R.ok();
    }

    @ApiOperation(value = "根据id删除")
    @DeleteMapping("/delete/{id}")
    public R delete(@PathVariable("id") Long id){
        couponService.removeById(id);
        return R.ok();
    }


}
